#pragma once
#include <vector>
using namespace std;
#include <math.h>
#include <fstream>

#include "SceneObject.h"
#include "FreeTrackData.h"

#define MAX_DIST 10000 // something large
#define SCREEN_WIDTH GetSystemMetrics(SM_CXSCREEN)
#define SCREEN_HEIGHT GetSystemMetrics(SM_CYSCREEN)

#define NUM_REGIONS_HORIZONTAL 4
#define NUM_REGIONS_VERTICAL 3

#define NUM_CALIB_REGIONS_HORIZONTAL 2
#define NUM_CALIB_REGIONS_VERTICAL 2

#define regionWidth (SCREEN_WIDTH / NUM_REGIONS_HORIZONTAL)
#define regionHeight (SCREEN_HEIGHT / NUM_REGIONS_VERTICAL)

//#define DEBUG

class Scene
{
public:
	Scene();
	~Scene();
	void addObject(SceneObject* s);
	void removeLastObject();

	void draw();
	void update();

	/* calculates and fills the region centers */
	void calibrateWithAngles(int numCalibrationPts);
	/* given angle data, finds the row and column id of the nearest region */
	/* centers must be filled in advance */
	void findNearestRegionId(float yaw, float pitch, int* regionId);

	void calculateRegionCenters();

	// TODO: write a struct like thing so that i can access regionAngles[i][j]->yaw
	float regionAngles[NUM_REGIONS_VERTICAL][NUM_REGIONS_HORIZONTAL][2];
	float regionCenters[NUM_REGIONS_VERTICAL][NUM_REGIONS_HORIZONTAL][2];

	vector <SceneObject*> sceneObjects;
	vector <FreeTrackData> headTrackData;

	bool sceneCalibrated; 

//#ifdef DEBUG
	unsigned int dataIndex; 
//#endif

};